---
title: "Error Sampler"
description: "This action is a [Global Action](/pipeline/actions/introduction#scope-categories) that supports error sampling by filtering out non-error traces."
sidebarTitle: "Error Sampler"
icon: "tag"
---

import BetaWarning from '/snippets/beta-warning.mdx';
import AssumeNoMeaning from '/snippets/assume-no-meaning.mdx';

<BetaWarning />

## Considerations

<Warning>
  Before enabling **probabilistic sampler**, please note the following:
  - Supports only traces.
  - All spans in a trace will be either entirely dropped or entirely sampled.
  - This action is a `global` action, meaning it applies to all traces in the system without filtering for specific services or endpoints.
  - Adding this action causes a 30-second delay in sending the data.
  - Traces with durations exceeding 30 seconds might not be sampled correctly.
</Warning>

## Use Cases

**Cost Reduction**

- Some vendors charge based on the amount of data ingested. For self hosted destinations, the cost is correlated to the use of cloud resources which grows with the based on the amount of data you process and store. By Reducing traces volumes, you can reduce the amount of data ingested and reduce costs.

**System Optimization**

- Error traces are typically more informative for identifying and resolving issues. By focusing only on error traces, developers can quickly pinpoint and address problems, optimizing system performance and reducing the time and resources spent on debugging non-critical traces.

## Configuration Options

The ErrorSampler action is configured using the `odigos.io/v1alpha1.Action` CRD with the `samplers` configuration section.

<AccordionGroup>
  <Accordion title="actionName">
    **actionName** `string` : Allows you to attach a meaningful name to the action for convenience.
    - This field is *optional*
    - <AssumeNoMeaning />
  </Accordion>
  <Accordion title="notes">
    **notes** `string` : Allows you to attach notes regarding the action for convenience.
    - This field is *optional*
    - <AssumeNoMeaning />
  </Accordion>
  <Accordion title="disabled">
    **disabled** `boolean` : Allows you to temporarily disable the action, but keep it saved for future use.
    - This field is *optional*, and defaults to `false`
  </Accordion>
  <Accordion title="signals *">
    **signals** `string[]` : An array with the signals that the action will operate on.
    - This field is *required*
    - Supported values: `TRACES`
  </Accordion>
  <Accordion title="samplers *">
    **samplers** `object` : Configuration for sampling actions.
    - This field is *required* for this action type
    <AccordionGroup>
      <Accordion title="errorSampler *">
        **errorSampler** `object` : Configuration for the ErrorSampler.
        - This field is *required* for this action type
        <AccordionGroup>
          <Accordion title="fallback_sampling_ratio *">
            **fallback_sampling_ratio** `number` : Specifies the ratio of non-error traces you still want to retain.
            - This field is *required*
            - For example: setting it to 50 ensures that 50% of the non-error traces will be retained.
          </Accordion>
        </AccordionGroup>
      </Accordion>
    </AccordionGroup>
  </Accordion>
</AccordionGroup>

## Basic Example

The following example demonstrates how to add a sampler that retains 100% of error traces and 50% of non-error traces using the new Action CRD.

<Steps>
  <Step>
    Create a YAML file with the following content:

    ```yaml error-sampler.yaml
    apiVersion: odigos.io/v1alpha1
    kind: Action
    metadata:
      name: example-error-sampler
      namespace: odigos-system
    spec:
      actionName: "configure-error-sampler"
      signals:
        - TRACES
      samplers:
        errorSampler:
          fallback_sampling_ratio: 50
    ```
  </Step>
  <Step>
    Apply the action to the cluster:

    ```bash
    kubectl apply -f error-sampler.yaml
    ```
  </Step>
</Steps>
